package com.liarjo.mywebsiteapi.admin.controller.systemInfo;

import org.springframework.stereotype.Service;

import oshi.SystemInfo;
import oshi.hardware.CentralProcessor;
import oshi.hardware.CentralProcessor.ProcessorIdentifier;
import oshi.hardware.GlobalMemory;
import oshi.software.os.OperatingSystem;

@Service
public class SystemInfoService {
    public SystemInfoResult systemInfo() {
        SystemInfo systemInfo = new SystemInfo();
        OperatingSystem operatingSystem = systemInfo.getOperatingSystem();
        CentralProcessor processor = systemInfo.getHardware().getProcessor();
		ProcessorIdentifier processorIdentifier = processor.getProcessorIdentifier();
        GlobalMemory memory = systemInfo.getHardware().getMemory();

        SystemInfoResult systemInfoResult = new SystemInfoResult();
        systemInfoResult.setOperatingSystem(operatingSystem.toString());
        systemInfoResult.setProcessor(processorIdentifier.getName());
        systemInfoResult.setMemory(memory.toString());

        return systemInfoResult;
    }
}
